package com.ruyuan.scholartrade.controller;

import com.scholar.shop.common.CommonRes;
import com.scholar.shop.trad.exchange.api.ExchangeGoodsAPI;
import com.scholar.shop.trad.exchange.domain.ExchangeRequest;
import com.scholar.shop.trad.exchange.domain.ExchangeResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author fk
 * @version v2.0
 * @Description:
 * @date 2018/8/21 16:14
 * @since v7.0.0
 */
@CrossOrigin
@RestController
@RequestMapping("/trade/exchange/open/api")
public class ExchangeGoodsAPIController {

    @Autowired
    private ExchangeGoodsAPI exchangeGoodsAPI;

    
    @PostMapping("/add")
    public CommonRes<ExchangeResponse> add(@RequestBody ExchangeRequest dto) {

        return exchangeGoodsAPI.add(dto) ;
    }

    
    @PostMapping("/edit")
    public CommonRes<ExchangeResponse> edit(@RequestBody ExchangeRequest request) {


        return exchangeGoodsAPI.edit(request) ;
    }

    
    @GetMapping("/getByGoodsId/{goodsId}")
    public CommonRes<ExchangeResponse> getModelByGoods(@PathVariable Integer goodsId) {

        return exchangeGoodsAPI.getModelByGoods(goodsId);
    }

    /**
     * 删除某个商品的积分兑换信息
     *
     * @param goodsId
     * @return
     */
    
    @DeleteMapping("/del/{goodsId}")
    public CommonRes<Boolean> del(@PathVariable Integer goodsId) {

        ;
        return exchangeGoodsAPI.del(goodsId) ;
    }
}
